// 引入模型
const goodsModel = require('../model/goodsModel')
const goods = {
  add(req, res) {
    let data = req.body
    goodsModel
      .insertMany([data])
      .then((rs) => {
        if (rs) {
          res.send({
            code: 0,
            msg: '添加商品成功',
            data: [rs]
          })
        } else {
          res.send({
            code: 1,
            msg: '添加商品失败',
            data: []
          })
        }
        console.log(rs)
      })
      .catch((err) => {
        console.log(err)
      })
  }
}
module.exports = goods